<template>
  <div class="search-history">
    <div class="top">
      <div class="title">
        <slot name="title">
          <!-- <span>历史记录</span> -->
        </slot>
      </div>
      <div class="img">
        <slot name="icons">
          <!-- <img src="@/assets/icon/del-address.png" alt="" /> -->
        </slot>
      </div>
    </div>
    <div class="main">
      <div
        @click="searchItemClick(item)"
        class="main-item"
        :class="item.is_hot == 1 ? 'activeColor' : ''"
        v-for="(item, index) in hotKeywordList"
        :key="index"
      >
        {{ item.keyword }}
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    hotKeywordList: {
      type: Array,
      default() {
        return [];
      },
    },
  },
  data() {
    return {
      curentIndex: null,
    };
  },
  methods: {
    searchItemClick(item) {
      // console.log(item)
      // let index = this.hotKeywordList.findIndex(items => items.keyword == item.keyword)
      // console.log(index)
      this.$emit('searchItemClick',item)
    }
  }
};
</script>

<style lang="scss" scoped>
.search-history {
  background-color: #fff;
  padding: 10px;
  .top {
    display: flex;
    height: 27px;
    justify-content: space-between;
    .img {
      width: 27px;
      img {
        width: 100%;
        vertical-align: middle;
      }
    }
  }
  .main {
    display: flex;
    flex-wrap: wrap;
    .main-item {
      padding: 5px;
      border: 1px solid #999999;
      margin-right: 20px;
      margin-bottom: 10px;
    }
    div.activeColor {
      border: 1px solid #f00;
    }
  }
}
</style>